#!/bin/bash

# 传递两个参数
# 1.gate_server的路径位置
# 2.目录名称 --- 将对应的库文件拷贝到目录中
declare depends
get_depends()
{
    # 将查找依赖的结果存储在depends中
    depends=$(ldd $1 | awk '{if (match($3,"/")){print $3}}')
    mkdir $2  
    cp -Lr $depends $2
}

get_depends ./file_server/build/file_server ./file_server/depends
get_depends ./gateway_server/build/gate_server ./gateway_server/depends
get_depends ./friend_server/build/friend_server ./friend_server/depends
get_depends ./message_server/build/message_server ./message_server/depends
get_depends ./user_server/build/user_server ./user_server/depends
get_depends ./transmit_server/build/transmit_server ./transmit_server/depends
get_depends ./speech_server/build/speech_server ./speech_server/depends

cp /bin/nc ./file_server
cp /bin/nc ./gateway_server
cp /bin/nc ./friend_server
cp /bin/nc ./message_server
cp /bin/nc ./user_server
cp /bin/nc ./transmit_server
cp /bin/nc ./speech_server

get_depends /bin.nc ./file_server/depends
get_depends /bin.nc ./gateway_server/depends
get_depends /bin.nc ./friend_server/depends
get_depends /bin.nc ./user_server/depends
get_depends /bin.nc ./transmit_server/depends
get_depends /bin.nc ./speech_server/depends
get_depends /bin.nc ./message_server/depends